<style>
#focus_<{$widgets_id}>{height:auto;}
#slide_<{$widgets_id}> a {width:9px;height:9px;margin:0 4px;background:#ccc;text-indent:-999em;position:relative;z-index:1520}
#slide_<{$widgets_id}> .active {background-color:#CB2228;}
</style>
<div id="focus_<{$widgets_id}>" class="qf-focus-goods">
     <div class="hd">
          <h3><b class="pngFix"></b><{$setting.title}></h3>          
          
          <div class="scroll clearfix">              
              <div class="slide-number l" id="slide_<{$widgets_id}>">             
                   <{assign var="do" value="0"}>
                   <{foreach from=$data.slideData item=item name=slidenum}>
                   <a href="javascript:void(0);" hidefocus="true" rel="nofollow" <{if $do==0}>class="active"<{/if}>>                   <{assign var="do" value=$do+1}><{$smarty.foreach.count.iteration}></a><{/foreach}>
              </div>
           </div>
     </div>  
     
  <div id="hightbox" class="hightbox">
     <a id="moveLefty_<{$widgets_id}>" href="javascript:void(0);" class="prev pngFix"></a>
     <a id="moveRighty_<{$widgets_id}>" href="javascript:void(0);" class="next pngFix"></a> 
    <ol id="flashvier_<{$widgets_id}>" class="switchable-viewbox clearfix">
    <{foreach from=$data.slideData item=item name=slidenum}>
    	<li class="slideitem_<{$widgets_id}>">
    	 <{foreach from=$item item=row key=gid name=goodsrow}>
         
         <div class="slide_iteminfo goods-item fore<{$do}><{if $do % $setting.column == 0}> last<{/if}>">
         <{assign var=pickey  value=$setting.gpic_size|default:'goodsPicM'}>
         <div class="goodpic"><a target="_blank" href="<{$row.goodsLink}>">
         <img src="<{$row[$pickey]}>" alt="<{$row.goodsName}>" data-img-zoom="true"/></a>
          </div>
          <div class="info clearfix">
             <div style="margin-bottom: 0;" class="goods-name"><a target="_blank" href="<{$row.goodsLink}>"><{$row.goodsName|cut:$setting.maxlength}></a></div>
             
              <{if $setting.showgoodsSalePrice == 'on' || $setting.showgoodsMarketPrice == 'on'}>
              
               <!-- 验证判断和价格和数量显示  黄智坤 -->
			 <{if $data.check_login == 'login'}>
                	<div class="item-price">
                    	<{if $setting.showgoodsSalePrice == 'on'}>
                      <span class="price">

                      <!--@zeng 2017.4.25 首页商品列表价格显示控制-->
                      <{if $row.products.1.info.member_state == '1'}>
                        <{$row.products.2.mlv_price|cur}>
                      <{else}>
                        <{$row.goodsSalePrice|cur}>
                      <{/if}>

                      </span>
                      <{/if}>
                        <{if $setting.showgoodsMarketPrice == 'on'}><del class="market-price"><{$row.goodsMarketPrice|cur}></del>
                        <{/if}>
                    </div> 
                    
                <{/if}>  
          </div>
		<!-- <span>BBB</span>	 -->
		<{/if}>
		<!-- 这里是验证--未登录不显示价格 -->
          <!--
          	作者：sihua
          	时间：2017-04-20
          	描述：购物车和数量
          -->
          
          <div class="goods-action" style="margin-left: 5px;">
	      
	        <div class="goods-buy">
	          <span class="product-buy-quantity">
		          <span class="item-content">
			          <span class="p-quantity">
			            <a href="javascript:void(0);" class="btn-decrease">-</a><input type="text" 
			            min="<{if $data.add.isused==1}><{$data.add.pernum}><{else}><{$row.peradd}><{/if}>" 
			            max="<{if $row.nostoreSell == 1}>999999999<{else}><{$row.products.0.store|number}><{/if}>" size="2" 
			            name="goods[num]" class="action-quantity-input" 
			            value="<{if $data.add.isused==1}><{$data.add.pernum}><{else}><{$row.peradd}><{/if}>">
			            <a href="javascript:void(0);" class="btn-increase">+</a>
			            <span class="p-store" style="float: left;"></span>
			            <input type="hidden" name="stock" value="<{if $row.nostoreSell==0}>{store}<{else}>999999999<{/if}>">
			        <!-- getPeradd 这个隐藏的输入框用于被批量设置的js取值（批量数） -->
			            <input type="hidden"  class="action-quantity-input-getPeradd"  value="<{$row.peradd}>">
			            <input type="hidden"  class="action-quantity-input-havegift"  value="<{$row.products.3.type}>">
			            <input type="hidden"  class="action-quantity-input-getmaxbuy"  value="<{if $row.products.3.type =='havegift'}><{$row.products.4.maxbuy|number}><{else}><{$row.products.0.store|number}><{/if}>">
			          </span>
		          </span>
	          </span>
	              <{if $env.conf.b2c.site.buy.target == '2'}>
		          <{assign var='buytarget' value='_blank_cart'}>
		          <{elseif $env.conf.b2c.site.buy.target == '3'}>
		          <{assign var='buytarget' value='_dialog_minicart'}>
		          <{/if}>
	          <input type="hidden" name="goods[goods_id]" value="<{$row.goodsId}>">
	          <input type="hidden" name="goods[product_id]" value="<{$row.products.0.product_id}>">
	          
              <a class="action-addtocart" href="<{link app=b2c ctl=site_cart act=add arg0=goods arg1=$row.goodsId arg2=$row.products.0.product_id arg3=1}>"<{if $buytarget}> target="<{$buytarget}>"<{/if}>>
              	<i class="icon">&#x3e;</i>
              </a>
	          
	        </div>
	       </div>
	       
		
          </div>      

        <{/foreach}>
        </li>
   	 <{/foreach}>
    </ol>
  </div>

</div>  	       

<script src="images/qf-wide-focus.js"></script>
<script type="text/javascript">
window.addEvent("domready",function(){
	var wid_<{$widgets_id}> = new qfFocus("flashvier_<{$widgets_id}>",{
		'periodical':'<{$setting.qfspeed|default:"5000"}>',
		'duration':'<{$setting.duration|default:300}>',		
		'direction':'<{if $setting.direction != '1'}>horizontal<{else}>vertical<{/if}>',
		'button': {
			'left':'moveLefty_<{$widgets_id}>',
			'right':'moveRighty_<{$widgets_id}>',
			'delay':100
		},
		'pagebtns': {
			'id':'slide_<{$widgets_id}>',
			'selected-class':'active'
		}
	}).init();
});
</script>


<!--
          	作者：sihua
          	时间：2017-04-20
          	描述：购物车和数量
          -->
<script>
bindQuantityEvent(focus_<{$widgets_id}>,setQuantity);
//== 为数量选择框绑定事件
function bindQuantityEvent(elements, callback) {
    elements = document.id(elements) || $$(elements);
    if(!elements && !elements.length) return;
    
  //= edit by hzk 每次点击的（加减）数量
    elements.addEvents({
        //= 数量按钮
        ////////////////////////////////////
	  //= edit by hzk 每次点击的（加减）数量
	       'click:relay(.btn-decrease,.btn-increase)': function(e) {

	           var res = 0;
	    	   var getPeradd = this.getParent().getElement('.action-quantity-input-getPeradd');
	            var input = this.getParent().getElement('.action-quantity-input');
	            value = +input.value;
	            
	            perclicknum= parseInt((<{$data.add.isused}> ==1) ?  <{$data.add.pernum}>  : parseInt(getPeradd.value)) ;
	            
	          //add by hzk 2017-5-18 提示赠品封顶数，
	            checknum=value+perclicknum;
	            checkmaxbuy(this, checknum,'button'); 
	            
/*                  alert(getPeradd.value);   */
	            
	         // input.value = this.hasClass('btn-decrease') ? (value - perclicknum) : (value + perclicknum);
	            peradd = this.hasClass('btn-decrease') ? (value - perclicknum) : (value + perclicknum);
	            
	            res = peradd - (peradd%perclicknum)

	            input.value = res;
	            
	            callback && callback(input, value);
	        },        
         
        ////////////////////////////////////
        //= 数量输入框
        'focus:relay(.action-quantity-input)': function(e){
            value = +this.value;
        
        },
        'change:relay(.action-quantity-input)': function(e) {
            //var getmaxbuy = this.getParent().getElement('.action-quantity-input-getmaxbuy');
            //if(getmaxbuy.value == value){
			//	Dialog.alert('该商品购买数量已达赠品优惠上限'+getmaxbuy.value+'，上限之后的购买数量将不赠送赠品，确定继续购买？');
            //}
            checkmaxbuy(this,value,'text');
            
            callback && callback(this, value);
        }
    });
}


//== 赠品封顶值提示方法 add by hzk 2017-5-18
function checkmaxbuy(e1, value,inputtype) {
	
	//alert(1);
	 //add by hzk 2017-5-18
    var checkgift = e1.getParent().getElement('.action-quantity-input-havegift');	           
    	//alert(checkgift.value);   
    if('havegift'==checkgift.value){
 	   var getmaxbuy = e1.getParent().getElement('.action-quantity-input-getmaxbuy');
   		// alert(getmaxbuy.value);   
        if(!e1.hasClass('btn-decrease')){  
        	
				if(inputtype=='button' && getmaxbuy.value == value){
					Dialog.alert('该商品购买数量已达赠品优惠上限'+getmaxbuy.value+'，上限之后的购买数量将不赠送赠品，确定继续购买？');
	            }else if(inputtype=='text' && getmaxbuy.value<=value){
					Dialog.alert('该商品仅在前'+getmaxbuy.value+'个商品赠送赠品，上限数量之后的购买数量将不赠送赠品，确定继续购买？');
	            }
		} 
    }
}

//== 获取商品数量值
function getQuantity(el, type) {
    return el.getElement('input[name=' + type + ']').value;
}
//== 设置商品数量
function setQuantity(input, value) {
    var type = 'product';
    var p = input.getParent('li');
    
    inputCheckSlide(input, {min: input.get('min'), max: input.get('max'), 'default': value, store: getQuantity(p, 'stock'), callback: window.quantityCallback});
}
//== 商品数量输入框正确性检测
function inputCheckSlide(input, options) {
    if(!input) return false;
    options = options || {};
    if(isNaN(options.min)) options.min = 1;
    if(isNaN(options.max)) options.max = 999999;
    options['default'] = options['default'] || options.min;
    var value = +input.value;
    var tips = new Tips(input);
    var pre = '';
    var msg = '';
    
    if(options.store && options.store - value <= 0) {
        pre = '库存有限，';
    }
    if(value < options.min) {
        input.value = options.min;
        msg = '此商品的最小购买数量为' + options.min + '件';
    }
    
    else if(value > options.max){
        input.value = options.max;
        msg = pre + '此商品最多只能购买' + options.max + '件';
    }
    
    else if(isNaN(value)) {
        input.value = options['default'];
        msg = '只允许输入数字';
    }
    if (msg) {
        tips.show(msg);
        return false;
    }
    tips.hide();
    if(options.callback) options.callback(input, options['default']);
    return true;
}

</script>
